<template>
  <tbody>
      <tr v-for="(obj,index) in goodList" :key="index">
        <td><input type="checkbox" :checked="obj.checked"  @change="iptitemchange(index)"></td>
        <td>{{obj.name}}</td>
        <td>{{obj.price}}</td>
        <td><button @click="subfn(index)">--</button> {{obj.num}} <button @click="addfn(index)">++</button></td>
        <td>{{obj.price*obj.num}}</td>
        <td><button @click="deletefn(index)">删除</button></td>
      </tr>
      </tbody>
</template>

<script>
import { mapState, mapMutations } from 'vuex'
export default {
  data () {
    return {

    }
  },
  computed: {
    ...mapState(['goodList'])
  },

  created () {

  },

  methods: {
    ...mapMutations(['subcount', 'addcount', 'deleteitem', 'changeitem']),
    addfn (ind) {
      this.subcount(ind)
    },
    subfn (ind) {
      this.addcount(ind)
    },
    deletefn (ind) {
      this.deleteitem(ind)
    },
    iptitemchange (ind) {
      console.log(111)
      this.changeitem(ind)
    }
  }
}
</script>

<style scoped lang='less'>
tbody {
  text-align: center;
}
</style>
